<%--
  Created by IntelliJ IDEA.
  User: hanfei
  Date: 18/7/25
  Time: 下午2:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.wuming.house.security.SecurityHander" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>新房分类</title>
    <link rel="stylesheet" href="${allServerPath}static/layui/layui/css/layui.css">
    <link rel="stylesheet" href="${allServerPath}static/layui/css/icon.css">
    <link rel="stylesheet" href="${allServerPath}static/layui/css/public.css">
</head>
<body style="background-color: #f0f2f5;" class="childrenBody">
<div class="layui-fluid wuli-main">
    <div class="layui-row">
        <form class="layui-form">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label wuli-width-auto">楼盘名</label>

                    <div class="layui-input-inline ">
                        <input type="text" name="houseName" lay-verify="title" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="layui-row wuli-button">
        <button id="btnQuery" type="button" class="layui-btn layui-btn-normal">查询搜索</button>
        <%--<button id="btnExport" type="button" class="layui-btn layui-btn-normal">导出表单</button>--%>
    </div>
    <div class="layui-row">
        <table class="layui-hide" id="reportInfo" lay-data="{height: 'full-200'}" lay-filter="reportinfo"></table>
        <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    </div>
</div>

<script src="${allServerPath}static/layui/layui/layui.js"></script>
<script>
    layui.use(['form', 'laydate', 'table'], function () {
        var table = layui.table,
            layer = layui.layer,
            laydate = layui.laydate,
            $ = layui.$;

        var cateId = ${cateId};
        table.render({
            elem: '#reportInfo'
            , url: '${allServerPath}web/house/listByCate/'+cateId+'.htmls?t=' + Date.parse(new Date())
            , cols: [[
                {type: 'checkbox'}
                , {field: 'houseName', align: 'center', title: '楼盘名'}
                , {field: 'area', align: 'center', title: '区域'}
            ]],
            id: 'reportContent',
            method: 'get', //如果无需自定义HTTP类型，可不加该参数
            page: true,
            request: {
                pageName: 'pageIndex', //页码的参数名称，默认：page
                limitName: 'pageSize'
            }, //如果无需自定义请求参数，可不加该参数
            response: {
                statusName: 'code' //数据状态的字段名称，默认：code
                , statusCode: 200 //成功的状态码，默认：0
                , msgName: 'message' //状态信息的字段名称，默认：msg
                , countName: 'total' //数据总数的字段名称，默认：count
                , dataName: 'data' //数据列表的字段名称，默认：data
            }, //如果无需自定义数据响应名称，可不加该参数
            done: function (res, curr, count) {
                //如果是异步请求数据方式，res即为你接口返回的信息。
                //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度
                console.log(res);

                //得到当前页码
                console.log(curr);

                //得到数据总量
                console.log(count);
            },
            text: {
                none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
            }
        });
        table.on('checkbox(reportinfo)',function (obj) {
            $.ajax({
                type: 'post',
                url: '${allServerPath}web/cateHouse/save.htmls',
                data: {
                    'cateId': ${cateId},
                    'houseId': obj.data.id
                },
                dataType: 'JSON',
                success: function (data) {
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                    layer.msg(data.message);
                },
                error: function () {
                }
            });
        });

        $("#btnQuery").click(function () {
            var houseName = $("input[name='houseName']").val();
            table.reload('reportContent', {
                page: {
                    curr: 1 //重新从第 1 页开始
                }
                , where: {
                    "houseName":houseName
                }
            });
        });
    });
</script>
</body>
</html>

